<?php


namespace Modules\Admin\Http\Controllers\Authorization\Permission;


use Modules\Common\Models\AdminPermission;
use Modules\Common\Util\Api;
use Modules\Common\Util\Database;

class Disable
{
    /**
     * @Route(path=/api/admin/authorization/permission/disable method=put)
     */
    public function index()
    {
        Api::validate(['permission_id' => 'integer']);
        $permission = AdminPermission::find(request('permission_id'));
        $disable = ($permission->disable == 0) ? 1 : 0;
        $permission->disable = $disable;
        $permission->save();
        return Api::success();
    }

}
